package csc.daonjpa.java.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import csc.daonjpa.java.dao.AccountDAO;
import csc.daonjpa.java.dao.CardDAO;
import csc.daonjpa.java.dao.CustomerDAO;
import csc.daonjpa.java.dao.TransactionDAO;
import csc.daonjpa.java.domain.Account;
import csc.daonjpa.java.domain.Card;
import csc.daonjpa.java.domain.Customer;
import csc.daonjpa.java.domain.Transaction;

@Controller
@RequestMapping(value="/adminpage")
public class AdminController {
	
	@Autowired
	private AccountDAO accountDAO;
	
	@Autowired
	private CardDAO cardDAO;
	
	@Autowired
	private CustomerDAO customerDAO;
	
	@Autowired
	private TransactionDAO transactionDAO;
	
	@RequestMapping
	public String goAdminPage(Model model){
		List<Account> accounts = accountDAO.getAccounts();
		model.addAttribute("accounts", accounts);
		
		List<Card> cards = cardDAO.getCards();
		model.addAttribute("cards", cards);
		
		List<Customer> customers = customerDAO.getCustomers();
		model.addAttribute("customers", customers);
		
		List<Transaction> transactions = transactionDAO.getTransactions();
		model.addAttribute("transactions", transactions);
		return "admin";
	}

}
